const express = require("express");
const router = express.Router();
const studentController = require("../controller/student");
const { validate } = require("../middleware/validation");
const { reg_add_student } = require("../validator/student");
// 文件上传插件
const multer = require("multer");
const path = require("path");

const upload = multer({
    dest: path.join(__dirname, "../public/upload/avatar")
});

// 添加学生
router.post("/addStudent", validate(reg_add_student), studentController.addStudent);
// 头像上传
router.post("/upload/avatar", upload.single("file"), studentController.uploadAvatar);
// 修改学生信息
router.post("/updateStudent", validate(reg_add_student), studentController.updateStudent);
// 获取学生列表
router.get("/getStudentList/:status/:page?/:pageSize?", studentController.getStudentList);
// 获取学生信息
router.get("/getStudentInfo/:id", studentController.getStudentInfo);
// 删除学生
router.delete("/deleteStudent/:id", studentController.deleteStudent);
// 批量删除学生
router.delete("/batchDeleteStudent", studentController.deleteStudentBatch);

module.exports = router;
